import resolve from 'rollup-plugin-node-resolve' // 告诉 Rollup 如何查找外部模块
import vue from 'rollup-plugin-vue'
import { terser } from 'rollup-plugin-terser' //压缩代码
import ts from 'rollup-plugin-typescript2'
import path from 'path'
import babel from 'rollup-plugin-babel'
import css from 'rollup-plugin-css-only'

const getPath = _path => path.resolve(__dirname, _path)
const extensions = [
  '.js',
  '.ts',
  '.tsx'
]
export default {
  input: "index.ts",
  output: [
    {
      file: 'dist/index.js',
      // 配置打包模块化的方式 es:ESM  cjs:CommonJS
      format: 'es'
    }
  ],
  external: ["vue", "ant-design-vue"],
  plugins: [
    resolve(),
    vue(),
    css({ output: 'index.css' }),
    // terser(),
    babel({
      exclude: 'node_modules/**', // 防止打包node_modules下的文件
      runtimeHelpers: true,       // 使plugin-transform-runtime生效
    }),
    ts({
      tsconfig: getPath('./tsconfig.json'), // 导入本地ts配置
      extensions
    })
  ]
};
